
import { useState } from "react"

export function useToggle(initialValue: boolean) {
  const [value, setValue] = useState(initialValue)
  const toggle = (value:boolean|never) => setValue(currentValue =>
     typeof value === 'boolean' ? value : !currentValue
    )


  return [value, toggle]
}